package com.ruoyi.monitorTools.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ruoyi.common.annotation.DataSource;
import com.ruoyi.common.enums.DataSourceType;
import com.ruoyi.monitorTools.domain.AisDynamicInfo;
import com.ruoyi.monitorTools.domain.DynamicInfo;
import com.ruoyi.monitorTools.service.AisDynamicInfoService;
import com.ruoyi.monitorTools.mapper.AisDynamicInfoMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;

/**
* @author Administrator
* @description 针对表【ais_dynamic_info】的数据库操作Service实现
* @createDate 2025-03-19 11:31:12
*/
@Service
@DataSource(value = DataSourceType.SLAVE)
public class AisDynamicInfoServiceImpl extends ServiceImpl<AisDynamicInfoMapper, DynamicInfo>
    implements AisDynamicInfoService{

    @Autowired
    private AisDynamicInfoMapper aisDynamicInfoMapper;

    @Override
    public Long selectMaxCreatetime() {
        QueryWrapper<DynamicInfo> queryWrapper = new QueryWrapper<>();
        queryWrapper.select("MAX(create_time) as max_create_date");
        DynamicInfo dynamicInfo = aisDynamicInfoMapper.selectOne(queryWrapper);
        return dynamicInfo.getCreateTime();
    }

    @Override
    public List<DynamicInfo> listAll() {
        QueryWrapper<DynamicInfo> queryWrapper = new QueryWrapper<>();
        queryWrapper.select("id", "mmsi as code");
        return aisDynamicInfoMapper.selectList(queryWrapper);
    }
}




